extends BaseLevel

# Interactables
@onready var gain_dash: Interactable = $Interactables/GainDash
@onready var gain_double_jump: Interactable = $Interactables/GainDoubleJump
@onready var gain_wall_jump: Interactable = $Interactables/GainWallJump

# Dialogs
@onready var dialog_dash: Dialog = $Dialogs/Dash
@onready var dialog_wall_jump: Dialog = $Dialogs/WallJump
@onready var dialog_double_jump: Dialog = $Dialogs/DoubleJump


func init_interactables() -> void:
	gain_dash.find_child("Sprite2D").frame = 0
	dialog_dash.disabled = true
	if GlobalGameData.GlobalEvents.has("HAS_DASH"):
		gain_dash.disabled = true
		gain_dash.find_child("Sprite2D").frame = 1
	gain_dash.action = func ():
		GlobalGameData.player_abilities.append(GlobalGameData.Abilities.DASH)
		GlobalGameData.GlobalEvents.append("HAS_DASH")
		gain_dash.find_child("Sprite2D").frame = 1
		gain_dash.disabled = true
		dialog_dash.disabled = false
	
	gain_double_jump.find_child("Sprite2D").frame = 0
	dialog_double_jump.disabled = true
	if GlobalGameData.GlobalEvents.has("HAS_DOUBLE_JUMP"):
		gain_double_jump.disabled = true
		gain_double_jump.find_child("Sprite2D").frame = 1
	gain_double_jump.action = func ():
		GlobalGameData.player_abilities.append(GlobalGameData.Abilities.DOUBLE_JUMP)
		GlobalGameData.GlobalEvents.append("HAS_DOUBLE_JUMP")
		gain_double_jump.find_child("Sprite2D").frame = 1
		gain_double_jump.disabled = true
		dialog_double_jump.disabled = false
	
	gain_wall_jump.find_child("Sprite2D").frame = 0
	dialog_wall_jump.disabled =  true
	if GlobalGameData.GlobalEvents.has("HAS_WALL_JUMP"):
		gain_wall_jump.disabled = true
		gain_wall_jump.find_child("Sprite2D").frame = 1
	gain_wall_jump.action = func ():
		GlobalGameData.player_abilities.append(GlobalGameData.Abilities.WALL_JUMP)
		GlobalGameData.GlobalEvents.append("HAS_WALL_JUMP")
		gain_wall_jump.find_child("Sprite2D").frame = 1
		gain_wall_jump.disabled = true
		dialog_wall_jump.disabled = false
